import java.util.Arrays;
import java.util.Random;

public class Aufgabe4 {

    /**
     * 
     * @author Christian Pysk
     * Matr.Nr: 1828317
     *
     */
    
    public static class TransportAuthority {
        private static String[] licensePlateList = new String[1000];
        private static String[] ownerList = new String[1000];
        private static String[] addressList = new String[1000];
        private static double[][] feeList = new double[1000][500];
        private static int[][] pointsList = new int[1000][500];
        private static int carsRegistered = 0;
        private static int[] delictsRegistered = new int[1000];        
        
        public void registerCar(String licensePlate, String owner, String address) {
            licensePlateList[carsRegistered % 1000] = licensePlate;
            ownerList[carsRegistered % 1000] = owner;
            addressList[carsRegistered % 1000] = address;
            delictsRegistered[carsRegistered % 1000]=0;
            System.out.println("Cars registered: " + ++carsRegistered);
        }
        
        public String getOwner(String licensePlate){
            for (int i=0; i<(carsRegistered % 1000); i++){
                if (licensePlateList[i].equals(licensePlate)) return ownerList[i];
            }
            return "License plate not registered";
        }

        public String getAddress(String licensePlate){
            for (int i=0; i<(carsRegistered % 1000); i++){
                if (licensePlateList[i].equals(licensePlate)) return addressList[i];
            }
            return "License plate not registered";
        }
        
        public void registerDelict(String licensePlate, double fee, int points){
            boolean found=false;
            for (int i=0; i<(carsRegistered % 1000); i++){
                if (licensePlateList[i].equals(licensePlate)) { 
                    feeList[i][delictsRegistered[i] % 500]=fee;
                    pointsList[i][delictsRegistered[i] % 500]=points;
                    found=true;
                    System.out.println("Delict registered for " + licensePlate + "! Currently " + ++delictsRegistered[i] + " delict(s) on record.");
                }            
            }
            if (!found) System.out.println("License plate not registered");
        }

        public double[] getFees(String licensePlate){
            for (int i=0; i<(carsRegistered % 1000); i++){
                if (licensePlateList[i].equals(licensePlate)) return feeList[i];
            }
            System.out.println("License plate not registered");
            return new double[0];
        }
        
        public int[] getPoints(String licensePlate){
            for (int i=0; i<(carsRegistered % 1000); i++){
                if (licensePlateList[i].equals(licensePlate)) return pointsList[i];
            }
            System.out.println("License plate not registered");
            return new int[0];
        }
    }
    
    public static TransportAuthority TA = new TransportAuthority();
    public static MeterMaid M1 = new MeterMaid();
    
    public static class MeterMaid {
        private static String currentPlate = "";
        
        public void checkCar(String licensePlate){
            currentPlate = licensePlate;
        }
        
        public void fine(){
            Random rand = new Random();
            TA.registerDelict(currentPlate, rand.nextInt(91)+10, rand.nextInt(4));
        }
        
        public void printTicket(){
            double[] feesList = TA.getFees(currentPlate);
            int[] pointsList = TA.getPoints(currentPlate);
            double fees = 0;
            int points = 0;
            System.out.println("Strafzettel: " + currentPlate + ", " + TA.getOwner(currentPlate) + ", " + TA.getAddress(currentPlate));
            for (int i=0; i<500; i++){
                fees += feesList[i];
                points += pointsList[i];
            }
            System.out.println("Strafen: " +  Arrays.toString(feesList));
            System.out.println("Punkte: " +  Arrays.toString(pointsList));
            System.out.println("Insgesamt " + fees + " Gebuehren und " + points + " Punkte");
        }

    }

    public static void main(String[] args) {        
        TA.registerCar("A-B 100", "Mueller", "Plangraben 1");
        TA.registerCar("A-C 101", "Maier", "Landstr. 3");
        M1.checkCar("A-C 101");
        M1.fine();
        M1.fine();
        M1.fine();
        M1.printTicket();
    }

}
